//Spawn selection module
//Created by MadCat
//Thanks to all SA-MP Script Developers for spawns! :)

forward SpawnSel_OnPlayerConnect(playerid);
forward SpawnSel_OnPlayerRequestSpawn(playerid);
forward SpawnSel_OnPlayerRequestClass(playerid,classid);

enum SpawnInfo {
	InteriorID,
	Float:Player_Pos_X,
	Float:Player_Pos_Y,
	Float:Player_Pos_Z,
	Float:Player_Angle,
	Float:Camera_Pos_X,
	Float:Camera_Pos_Y,
	Float:Camera_Pos_Z,
	Float:Camera_Look_At_X,
	Float:Camera_Look_At_Y,
	Float:Camera_Look_At_Z
}

#define MAX_SELECTPOS 66

new SpawnSelection[MAX_PLAYERS];

new Spawns[MAX_SELECTPOS][SpawnInfo] = {
{0,1292.0852,-801.3420,96.4609,350.8139,1292.2723,-799.1179,97.4609,1292.0852,-801.3420,97.0000}, // PEN1: SA Default
{0,1000.0198,-1022.3301,42.7101,179.0234,999.9587,-1025.9143,42.7101,1000.0198,-1022.3301,42.7101}, // Project: San Andreas Default
{0,380.7409,-2020.7327,10.2500,153.0111,379.4443,-2024.7115,10.3075,380.7409,-2020.7327,10.2500}, // LS Beach View. By BetaMaster
{0,407.2467,-1377.2729,42.6563,194.8367,408.4313,-1381.5542,42.6563,407.2467,-1377.2729,42.6563}, // LS Call Girls Only Billboard. By BetaMaster
{0,2141.9114,-1041.7058,71.8125,294.5335,2146.6421,-1039.2510,71.8125,2141.9114,-1041.7058,71.8125}, // LS City View. By BetaMaster
{0,-2541.8586,1377.2490,7.0391,210.2330,-2539.6711,1373.4955,7.0391,-2541.8586,1377.2490,7.0391}, // SF Gant Bridge. By BetaMaster
{0,-1528.6282,833.8856,7.0391,288.5003,-1523.0333,835.7573,7.1875,-1528.6282,833.8856,7.0391}, // SF City View. By BetaMaster
{0,-2050.4214,-859.0068,32.1719,330.7435,-2048.5317,-855.5908,32.1719,-2050.4214,-859.0068,32.1719}, // SF Foster Valley. By BetaMaster
{0,958.7595,2566.3040,10.6762,73.0266,952.5722,2568.8020,10.6493,958.7595,2566.3040,10.6762}, // LV Welcome Sign. By BetaMaster
{0,2645.9673,2270.5615,18.1360,217.0452,2648.4231,2267.3083,18.1360,2645.9673,2270.5615,18.1360}, // LV Rock Hotel. By BetaMaster
{0,2370.6733,2165.4172,26.9844,290.6556,2373.7168,2166.5835,26.9844,2370.6733,2165.4172,26.9844}, // LV Old Strip. By BetaMaster
{0,-416.8759,2710.6060,62.3981,39.5556,-419.8005,2714.1479,62.2690,-416.8759,2710.6060,62.3981}, // Country The Big Pecker. By BetaMaster
{0,-2055.1760,-2462.4214,35.2889,294.2983,-2052.7932,-2461.3457,34.8259,-2055.1760,-2462.4214,35.2889}, // Country Bait Shop (Angel Pine). By BetaMaster
{0,861.5573,-27.3402,64.2777,296.8486,866.3002,-25.4593,64.2777,861.5573,-27.3402,64.2777}, // Country Fern Ridge. By BetaMaster
{6,345.3391,303.3166,999.9382,358.5782,345.4481,307.7208,999.9382,345.3391,303.3166,999.9382}, // Millie's Bedroom. By BetaMaster
{1,245.9927,303.4679,1000.0068,23.6664,244.9366,305.8774,1000.0068,245.9927,303.4679,1000.0068}, // Denise's Bedroom. By BetaMaster
{6,744.6722,1442.6976,1102.7031,218.4377,746.8713,1439.9269,1102.9531,744.6722,1442.6976,1102.7031}, // Fanny Batter's Whore House. By BetaMaster
{11,508.2252,-84.8755,998.9609,10.7533,508.5678,-80.1576,1000.00,508.2252,-84.8755,998.9609}, // Original GTO, Lil's Probe Inn.
{0,713.6481,-1634.0034,2.7164,-90.0,716.2721,-1633.9612,2.4297,713.6481,-1634.0034,2.7164}, // LS, near boats. From CountrySide RolePlay
{14,258.4893,-41.4008,1002.0234,270.0,256.0815,-43.0475,1004.0234,258.4893,-41.4008,1002.0234}, // Moneygrub Default :) And other...
{3,-2654.4,1424.2,912.4,90.0,-2655.9,1424.2,913.1,-2654.4,1424.2,913.1}, // PEN1: LS Default
{0,958.7595,2566.3040,10.6762,73.0266,952.5722,2568.8020,10.6493,958.7595,2566.3040,10.6762}, // PEN1: LV Default
{0,1685.5280,-2240.3850,13.5469,0.0,1685.5280,-2237.3850,13.5469,1685.5280,-2240.3850,13.5469}, // PureRP Default
{1,450.7622,-20.1152,1001.1328,90.0,445.7622,-20.1152,1001.7,445.7622,-20.1152,1001.7}, // SF Fugitive Default
{0,-1657.5237,1207.6644,13.6719,357.6906,-1657.4678,1211.2292,13.6781,-1657.5237,1207.6644,13.6719}, // The GodFather Default
{0,2303.7451,2122.5498,32.8281,88.0,2296.6389,2121.4065,32.8281,2303.7451,2122.5498,32.8281}, // Deathmatch RPG Default
{0,388.3286,-2024.4844,8.8203,90.0,380.4250,-2020.8900,10.2500,388.3286,-2024.4844,8.8203}, // GTAT Module Testing Script Default
{0,2682.7673,-1680.1404,9.4193,352.2312,2683.1050,-1674.7749,9.4287,2682.0964,-1691.6710,9.4207}, // Adrenaline Racing Default
{9,315.7802,972.0253,1961.8705,0.0,315.7802,975.0253,1961.8705,315.7802,972.0253,1961.8705}, // Area51 Break-In Default
{0,432.6625,-1747.4736,10.0974,270.3264,441.2379,-1748.0676,8.8827,432.6625,-1747.4736,10.0974}, // Area69 Madness Default
{0,803.0713,-1608.8990,22.5345,275.8504,808.0,-1608.9346,26.0,803.0713,-1608.8990,22.5345}, // Bartenders vs Customers Default
{0,368.8639,-2027.3770,7.6710,88.0,366.7747,-2027.2203,6.7,368.8639,-2027.3770,7.6719}, // Los-Santos Takeover Default
{3,2496.0,-1696.9,1014.8,0.0,2496.0,-1693.9,1015.8,2496.0,-1696.9,1014.8}, // Public Uprising 1.5, CJ Selection
{0,2585.0,2824.7,10.9,90.0,2581.5,2827.7,12.0,2585.0,2824.7,10.9}, // Public Uprising 1.5, Citizen Selection
{5,2348.2,-1172.6,1027.9,0.0,2346.2,-1170.6,1029.9,2348.2,-1172.6,1027.9}, // Public Uprising 1.5, Tramp Selection
{0,2459.3525,-1690.1758,13.5462,0.0,2459.3525,-1687.1758,15.5462,2459.3525,-1690.1758,13.5462}, // Public Uprising 1.5, Grove Selection
{10,1991.9780,1017.8176,994.8906,270.0,1993.9780,1017.8176,995.8906,1991.9780,1017.8176,994.8906}, // Public Uprising 1.5, Woozie Selection
{0,-2022.3262,158.2901,28.8359,270.0,-2016.3262,158.2901,31.8359,-2022.3262,158.2901,28.8359}, // Public Uprising 1.5, Rebel Selection
{0,1256.1487,-791.2058,92.0313,28.4421,1254.3755,-787.7794,92.0302,1256.1487,-791.2058,92.0313}, // LVDM ~MoneyGrub(+LandGrab) +PitBoss+GangDM Default
{0,398.4077,2540.5049,19.6311,180.0,398.4077,2530.5049,19.6311,398.4077,2540.5049,19.6311}, // Montster Freeroam Default
{0,2495.0449,2773.0566,10.8158,88.0,2490.9556,2773.1326,10.7968,2495.0449,2773.0566,10.8158}, // Minigun Madness
{0,1958.3783,1343.1572,15.3746,0.0,1958.3783,1347.1572,16.3746,1958.3783,1343.1572,15.3746}, // Man Hunt
{0,1545.5275,-1370.0961,329.4535,0.0,1545.5275,-1365.0961,329.4535,1545.5275,-1370.0961,329.4535}, // Parachuting
{0,-2087.6365,171.1811,38.0798,270.0,-2080.6365,171.1811,38.0798,-2087.6365,171.1811,38.0798}, // Building Site Gun Game
{0,1652.4760,942.7229,10.8203,180.0,1652.2588,938.5790,10.8203,1651.1898,945.2223,10.8203}, // dm_contained
{0,1984.4445,157.9501,55.9384,0.0,1984.4445,160.9501,55.9384,1984.4445,157.9501,55.9384}, // Rivershell
{0,2880.6147,-1592.9464,21.9528,76.7198,2871.6843,-1589.5769,22.4533,2880.6147,-1592.9464,21.9528}, // Impossible parking
{6,2336.0,-1066.0,1049.0,43.0,2333.0,-1063.0,1050.0,2336.0,-1066.0,1049.0}, // Military Hardware
{0,1365.922,-1278.569,24.80315,90.0,1355.3783,-1278.866,20.3746,1365.922,-1278.569,24.80315}, // Gun Game
{0,245.4394,-59.5369,1.5776,154.0,244.8021,-63.3422,1.5781,245.4394,-59.5369,1.5776}, // Mothertruckers Revenge
{0,219.3713,1369.0057,29.0093,180.0,219.3713,1361.4479,29.8386,219.3713,1369.0057,29.0093}, // Oil Refinery DM
{0,-1389.7386,659.9529,84.0078,5.0,-1391.0818,670.9420,92.5133,-1389.7386,659.9529,84.0078}, // de_ship
{0,1626.9666,-2287.5774,94.1270,270.0,1634.0,-2290.0,94.1270,1626.9666,-2287.5774,94.1270}, // Nevada Escape
{17,486.0,-13.0,1000.0,270.0,489.0,-13.0,1001.5,486.0,-13.0,1001.0}, // CTF City Wars
{0,1751.0969,-1094.1074,47.2801,160.0,1751.0969,-1098.1074,49.2990,1751.1800,-1090.1074,47.2150}, // Free For All 1.5
{0,1544.114,-1353.501,329.474,270.0,1548.114,-1353.501,330.474,1544.114,-1353.501,329.474}, // Prison Break 3.0
{0,-1319.6440,2523.3376,92.7802,180.0,-1319.5641,2516.4019,92.5406,-1319.6440,2523.3376,92.7802}, // de_aldeamalvada
{0,-1397.0,1482.0,11.8084,70.0,-1402.0,1479.0,12.0,-1397.0,1482.0,11.8084}, // Protect the Prime Minister Location 2
{0,-346.3293,1626.5712,136.3119,0.0,-351.3293,1629.5712,141.3119,-346.3293,1626.5712,136.3119}, // Protect the Prime Minister Location 3
{0,324.4081,1847.7921,7.5,90.0,314.4081,1847.7921,8.3,324.4081,1847.7921,7.5}, // Protect the Prime Minister Location 4
{0,435.355652,2532.222900,26.623209,0.0,435.355652,2535.222902,26.623209,435.355652,2532.222900,26.623209}, //Underworld roleplay
{5,323.4,305.6,999.1,90.0,320.9,305.6,999.8,322.4,305.6,999.8}, //SFRL 0.3, Blue Team
{18,-225.0508,1398.5399,28.3595,140.0,-227.2229,1395.5911,28.3595,-225.0508,1398.5399,29.0595}, //PEN1: Desert
{0,2182.2908,1285.7317,42.9620,89.8567,2177.5269,1285.3782,44.0867,2182.2908,1285.7317,42.9620}, //PEN1 Ultimate LS+SF+LV
{3,512.8511,-17.5289,1001.5653,328.6663,514.8894,-14.1297,1002.5653,512.8511,-17.5289,1001.5653}, //Forget, sorry
{17,485.08,-12.59,1000.68,90.0,481.52,-11.53,1001.38,485.19,-12.59,1001.38} //PEN1: Reborn

};

public SpawnSel_OnPlayerConnect(playerid) {
	SpawnSelection[playerid] = random(MAX_SELECTPOS);
	return 0;
}

public SpawnSel_OnPlayerRequestSpawn(playerid) {
	SpawnSelection[playerid] = random(MAX_SELECTPOS);
	return 0;
}

public SpawnSel_OnPlayerRequestClass(playerid,classid)
{
    	#pragma unused classid
	new sp=SpawnSelection[playerid];
   	Debug("spawn.inc > Player_OnPlayerRequestClass - Start");
	SetPlayerInterior(playerid,Spawns[sp][InteriorID]);
	oSetPlayerPos(playerid,Spawns[sp][Player_Pos_X],Spawns[sp][Player_Pos_Y],Spawns[sp][Player_Pos_Z]);
	SetPlayerFacingAngle(playerid, Spawns[sp][Player_Angle]);
	SetPlayerCameraPos(playerid,Spawns[sp][Camera_Pos_X],Spawns[sp][Camera_Pos_Y],Spawns[sp][Camera_Pos_Z]);
	SetPlayerCameraLookAt(playerid,Spawns[sp][Camera_Look_At_X],Spawns[sp][Camera_Look_At_Y],Spawns[sp][Camera_Look_At_Z]);
	SetPlayerVirtualWorld(playerid,PrivateWorld(playerid));
	Debug("spawn.inc > Player_OnPlayerRequestClass - Stop");
}